"""
@Time ： 2021/10/23 18:29
@Auth ： ChenZhangKun
"""


class MusicPlayer(object):
    # 定义类对象
    instance = None
    # 初始化标价
    isInit = False

    def __new__(cls, *args, **kwargs):
        # 是否已经初始化
        if cls.instance is None:
            # 进行初始化
            cls.instance = super().__new__(cls)
        return cls.instance

    def __init__(self):
        # 执行标记
        if not MusicPlayer.isInit:
            print("初始化播放器了")
            # 取反
            MusicPlayer.isInit = True


player1 = MusicPlayer()
player2 = MusicPlayer()

print(player1 is player2)
